﻿
Public Module unittest
    Private Sub write_machine_selector(ByVal m As machine_selector)
        Static tabs As String = character.tab + character.tab + character.tab
        Console.WriteLine(tabs + "machines count " + Convert.ToString(m.size()))
        Dim it As machine_selector.iterator = Nothing
        it = m.begin()
        While it <> m.end()
            Console.WriteLine(tabs + character.tab + (+it))
            it += 1
        End While
    End Sub

    Private Sub write_step(ByVal s As [step])
        Console.WriteLine(character.tab + "machine_selector count " + Convert.ToString(s.size()))
        Dim it As [step].iterator = Nothing
        it = s.begin()
        While it <> s.end()
            write_machine_selector(+it)
            it += 1
        End While
    End Sub

    Public Sub distrrule_unittest()
        Dim s As String = Nothing
        s = Console.ReadLine()
        While Not s Is Nothing
            Dim r As distrrule = Nothing
            If distrrule.parse(s, r) Then
                raiseError("parse success, step count " + Convert.ToString(r.size()))
                Dim it As distrrule.iterator = Nothing
                it = r.begin()
                While it <> r.end()
                    Console.WriteLine("step")
                    write_step(+it)
                    it += 1
                End While
            Else
                raiseError("cannot parse rule " + s)
            End If
            s = Console.ReadLine()
        End While
    End Sub
End Module
